home *** CD-ROM | disk | FTP | other *** search
- /*
- * Request.c - open an "rtEZRequestTags()" from script files
- *
- * PUBLIC DOMAIN
- *
- * by Stefan Sticht
- *
- * V1.00 Stefan Sticht initial release
- * V1.01 Stefan Sticht using cres.o for residentability
- * V1.02 08 Sep 1991 Stefan Sticht added options "defpubscreen", "frontpubscreen"
- * renamed option "screen" in "pubscreen"
- * V1.03 16 Sep 1991 Stefan Sticht removed error lockfrontpubscr()
- * V1.04 03 Apr 1992 Stefan Sticht changed version string
- * V2.00 13 Jan 1994 Goncalves Georges changed version string and replaced
- * EasyRequest() by rtEZRequestTags()
- * which is faster, user friendly and
- * allows underscores, text centering,
- * default response. Size increased to
- * 3528 bytes ( was 2404 ).
- *
- * V2.01 12 Mar 1994 Goncalves Georges Recompiled with version 6.51 of
- * compiler with optimisation on. Size
- * reduced and is smaller than the
- * original ( 2404 ). Now 1935 bytes!
- *
- * V2.02 05 Apr 1994 Goncalves Georges Removed a big error! an added a
- * NoDefault option to get rid of the
- * default gadget. Reduced again the
- * size ( 1912 bytes! ).
- *
- * V2.03 10 Nov 1994 Goncalves Georges Added a FLASH option to flash screen
- * when requester appears. Added some
- * equivalents for args template.
- *
- *
- * Use SAS/C 6.0 minimum to compile (or adapt the MakeFile). this version
- * was compiled with SAS/C 6.51
- *
- */
-
- #include "Includes.h"
-
- //[ "The main() function..."
- struct Screen *lockfrontpubscr(void);
-
- /*
- * some SAS/C specularities, change for other compilers!
- */
- #ifdef __SASC
- extern struct Library *DOSBase; /* Library base pointer from startup code */
- extern struct Library *SysBase; /* Library base pointer from startup code */
-
- // void chkabort(void) {} /* disable Ctrl-C detect */
- // This one has been included in SAS/C 6.51 so remove the double slashes if
- // you use an earlier version.
-
- #endif
-
- /*
- * a string, which will be found by Version
- */
- char version[] ="\0$VER: Request 2.03 (10/11/94) by Stefan Sticht and Goncalves A. Georges";
-
- struct Library *ReqToolsBase;
- struct IntuitionBase *IntuitionBase;
-
- /*
- * dummy window, we have to open
- */
- struct NewWindow dummywindow = {
- 0, 0,
- 1, 1,
- (unsigned char)-1, (unsigned char)-1,
- 0l,
- BORDERLESS | BACKDROP | SIMPLE_REFRESH,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- 0, 0,
- 0, 0,
- CUSTOMSCREEN
- };
-
- #define TEMPLATE "TEXT/A,TITLE/K,GADS=GADGETS/K,C=CENTER/S,DEF=DEFAULT/K/N,NODEF=NODEFAULT/S,FLASH/S,PS=PUBSCREEN/K,DEFPS=DEFAULTPUBSCREEN/S,FRONTPS=FRONTPUBSCREEN/S"
- #define OPT_TEXT 0
- #define OPT_TITLE 1
- #define OPT_GADGETS 2
- #define OPT_CENTER 3
- #define OPT_DEFAULT 4
- #define OPT_NODEFAULT 5
- #define OPT_FLASH 6
- #define OPT_PUBSCREEN 7
- #define OPT_DEFPUBSCREEN 8
- #define OPT_FRONTPUBSCREEN 9
- #define OPT_COUNT 10
-
- /*
- * this array will be filled by ReadArgs()
- */
- long options[OPT_COUNT];
-
- struct Screen *lockfrontpubscr(void)
- {
- struct Screen *scr;
- struct Screen *pubscr = NULL;
- struct List *pslist;
- struct PubScreenNode *psnode;
- unsigned long lock;
- unsigned short screentype;
-
- lock = LockIBase(0l);
-
- if (scr = IntuitionBase->FirstScreen) {
-
- screentype = scr->Flags & SCREENTYPE;
-
- UnlockIBase(lock);
-
- if (screentype == PUBLICSCREEN || screentype == WBENCHSCREEN) {
-
- if (pslist = LockPubScreenList()) {
-
- for (psnode = (struct PubScreenNode *)pslist->lh_Head;
- psnode->psn_Node.ln_Succ && (psnode->psn_Screen != scr);
- psnode = (struct PubScreenNode *)psnode->psn_Node.ln_Succ);
-
- if (psnode && (psnode->psn_Screen == scr) && !(psnode->psn_Flags & PSNF_PRIVATE)) {
-
- pubscr = LockPubScreen(psnode->psn_Node.ln_Name);
-
- }
-
- UnlockPubScreenList();
-
- }
-
- }
-
- }
-
- else UnlockIBase(lock);
-
- return(pubscr);
- }
-
- char *Title;
- char *Gadgets;
- char *Text;
- long Center = NULL;
- LONG Default;
-
- void _main(char *line)
- {
- struct RDArgs *args;
- struct Screen *scr = NULL;
- struct Window *win;
- char *screen = NULL;
- long rc;
- unsigned short defpubscreen = TRUE;
-
- if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37l))
- && (ReqToolsBase = OpenLibrary("reqtools.library", 38L)))
- {
-
- if (args = ReadArgs((UBYTE *)TEMPLATE, options, NULL))
- {
-
- if (options[OPT_TITLE])
- Title = (char *)options[OPT_TITLE];
-
- if (options[OPT_GADGETS])
- Gadgets = (char *)options[OPT_GADGETS];
- else
- Gadgets = "Okay";
-
- if (options[OPT_TEXT])
- Text = (char *)options[OPT_TEXT];
-
- if (options[OPT_CENTER])
- Center = EZREQF_CENTERTEXT;
-
- if ( options[OPT_DEFAULT] )
- Default = *( (LONG *)options[OPT_DEFAULT] );
- else
- Default = 1L;
-
- if ( options[OPT_NODEFAULT] )
- Default = -1L;
-
- if (options[OPT_PUBSCREEN])
- {
- screen = (char *)options[OPT_PUBSCREEN];
- defpubscreen = FALSE;
- }
-
- if (options[OPT_DEFPUBSCREEN])
- defpubscreen = TRUE;
-
- /*
- * try to lock a screen according to switches
- */
- if ((options[OPT_FRONTPUBSCREEN] && (scr = lockfrontpubscr())) ||
- (!scr && screen && *screen && (scr = LockPubScreen(screen))) ||
- (!scr && defpubscreen && (scr = LockPubScreen(NULL))))
- {
-
- dummywindow.Screen = scr;
- /*
- * try to open visitor window
- */
- if(win = OpenWindow(&dummywindow))
- {
- if ( options[ OPT_FLASH ] )
- DisplayBeep( NULL );
- rc = rtEZRequestTags( Text, Gadgets, NULL, NULL,
- RT_Window, (struct Window *) win,
- RT_Underscore, '_',
- RTEZ_DefaultResponse, Default,
- RTEZ_ReqTitle, Title,
- RTEZ_Flags, Center,
- TAG_END);
- }
- /*
- * don't forget closing the window
- */
- if (win) CloseWindow(win);
- /*
- * now unlock the screen
- */
- UnlockPubScreen(NULL, scr);
- }
-
- else
- {
- /*
- * public screen not found
- */
- PutStr("Can't find or lock screen!\n");
- rc = 20l;
- }
-
- }
-
- else
- {
- /*
- * error parsing options
- */
- PutStr("wrong number of arguments\n");
- rc = 40l;
- }
-
- /*
- * free arguments and close the lib
- */
- FreeArgs(args);
- CloseLibrary((struct Library *)IntuitionBase);
- CloseLibrary((struct Library *)ReqToolsBase);
-
- }
-
- else
- {
- /*
- * we really need intuition lib
- *
- * don't use PutStr() here, because dos.library could be < v36
- */
- Write(Output(), "Can't open intuition.library V37+ and/or reqtools.library V38+ !!!\n", 66l);
- rc = 30l;
- }
- exit(rc);
- }
- //]
-